﻿using System;
using System.Diagnostics;

namespace AzurePlugin.Converter
{
    public class ConverterTraceSource : TraceSource
    {
        public ConverterTraceSource(string name) : base(name)
        {
        }

        public ConverterTraceSource(string name, SourceLevels defaultLevel) : base(name, defaultLevel)
        {
        }

        public void TraceError(string message)
        {
            TraceEvent(TraceEventType.Error, getEventId(), message);
        }

        public void TraceWarning(string message)
        {
            TraceEvent(TraceEventType.Warning, getEventId(), message);
        }

        public void TraceError(Exception exception)
        {
            TraceData(TraceEventType.Error, getEventId(), exception.Message + exception.StackTrace);
        }

        private int getEventId()
        {
            return (int)DateTime.Now.Ticks;
        }
    }
}
